﻿using System;
using Game.ExtensibleObjects;

namespace Game.Map.Extensions
{
    public static class ClickExtensionHelper
    {
        public static MapClickExtension ClickX(this IGameMap map)
        {
            return map.Extensions.Find<MapClickExtension>();
        }
    }

    public class MapClickExtension : IRuntimeExtension
    {
        public event EventHandler<GameMapEventArgs> Click;

        public void DoClick(IMapFieldView field)
        {
            if (Click == null) return;

            Click(this, new GameMapEventArgs { MapField = field });
        }

    }

    public class MapClickExtensionFactory : IRuntimeExtensionFactory
    {
        public IRuntimeExtension CreateExtension(IRuntimeExtensibleObject source)
        {
            return new MapClickExtension();
        }
    }
}
